// 用户请求相关模块

import request from '@/uitls/request'
// import store from '@/store'

export const login = data => {
  return request({
    method: 'POST',
    url: '/v1_0/authorizations',
    data
  })
}

// 发送验证码 每个手机一分钟发送一次
export const sendSms = mobile => {
  return request({
    method: 'GET',
    url: `/v1_0/sms/codes/${mobile}`
    // /app/v1_0/sms/codes
  })
}

// 获取用户自己的信息
export const getUserInfo = () => {
  return request({
    method: 'GET',
    url: '/v1_0/user'
    // 发送请求头数据
    // headers: {
    // 该接口需要授权才可以访问
    // token的数据格式：Bearer token数据
    //   Authorization: `Bearer ${store.state.user.token}`
    // }
  })
}

// 获取用户频道列表
export const getUserChannels = params => {
  return request({
    method: 'GET',
    url: '/v1_0/user/channels',
    params
  })
}

// 关注用户
export const getFollow = target => {
  return request({
    url: '/v1_0/user/followings',
    method: 'POST',
    data: {
      target
    }
  })
}

// 取消关注用户
export const delFollow = target => {
  return request({
    url: `/v1_0/user/followings/${target}`,
    method: 'DELETE'
  })
}

// 获取用户个人信息/v1_0/user/profile
export const getProfile = () => {
  return request({
    url: '/v1_0/user/profile',
    method: 'GET'
  })
}

// 修改用户个人信息 /v1_0/user/profile
export const updateProfile = data => {
  return request({
    url: '/v1_0/user/profile',
    method: 'PATCH',
    data
  })
}

// 修改用户头像 /v1_0/user/photo
export const updatePhoto = data => {
  return request({
    url: '/v1_0/user/photo',
    method: 'PATCH',
    data
  })
}

